#include <font_manager.h>
#include <stdio.h>
#include <string.h>

 
static PFontOrp g_ptFontOrp = NULL;//
/*构造一个链表，用于注册底层freetype，点阵显示等结构体*/
static PFontOrp g_ptFontDefault = NULL;

 
/*传入结构体指针，把字体结构体注册进链表中*/
void RegisterFontOrpForGround(PFontOrp ptFontOrp) 
{
    ptFontOrp->ptNext = g_ptFontOrp;//链表头插入
    g_ptFontOrp = ptFontOrp;
}

void FontOrpsRegisterInList(void)
{
    extern void FreetypeRegisterFont(void);
    FreetypeRegisterFont();
}
 

 
/*遍历链表，选择默认的显示设备并初始化*/
int SelectAndInitFont (char *name ,char *afilename )
{
    PFontOrp Ptemp = g_ptFontOrp;//局部变量储存已经注册的显示设备
    while(Ptemp)
    {/*遍历链表*/
    if(strcmp(name, Ptemp->name) == 0)
    {// 名字相同选择该结构体
        g_ptFontDefault = Ptemp;
        g_ptFontDefault->FontInin(afilename);
        return 0;
    }
    /*如果名字不相同，进入下一个结构体再判断*/
    Ptemp = Ptemp->ptNext;
    }
    return -1;
}


int SetFontSize(int FontSize)
{
    int ret;
    ret = g_ptFontDefault->SetFontSize(FontSize);
    if(ret)
    {
        printf("set font size error\n");
        return -1;
    }
    return 0;
}

int GetFontBitmap(unsigned int dwCode, PFontBitmap ptFontBitmap)
{
    return g_ptFontDefault->GetFontBitmap(dwCode, ptFontBitmap);
}
